var symptomName = last_year_month();


$(function(){


  init();

})

 function init(){

   var myColor = ['#1089E7', '#F57474', '#56D0E3', '#F8B448', '#8B78F6'];

   //3_1
   var histogramChart1 = echarts.init(document.getElementById('histogramChart1'));
   $.ajax({
       type: "get",
       async: false,
        url: "http://120.79.23.50:9988/AA/data/3_1.json", 
		context: document.body,
       success: function(data){
		  console.log(data);
		  var a=["低档","中档","高档"];

		  histogramChart1.setOption({
	color:['#87cefa'],
      grid:{
          left: '5%',
          right: '5%',
          bottom: '5%',
          containLabel: true
      },
      tooltip : {
         trigger: 'item',
         formatter: "{a}<br/>{b}<br/>{c}元"
     },
      calculable : true,
      xAxis : [
          {
              type : 'category',
              data : a,
              axisLine:{
                   lineStyle:{
                       color: '#87cefa'
                   },
               },
               axisLabel : {
                 interval:0,
                 rotate:40,

                   textStyle: {
                       color: '#fff',
                       fontSize:20
                   }
               }
          }
      ],
      yAxis : [
          {
              type : 'value',
              axisLine:{
                  lineStyle:{
                      color: '#87cefa'
                  },
              },
              splitLine: {
                  "show": false
              },
              axisLabel: {
                  textStyle: {
                       color: '#fff',
                       fontSize:20
                   },
                  formatter: function (value) {
                      return value
                  },
              },
          }
      ],
      series : [
          {
              name:'平均价格',
              type:'bar',
              barWidth:30,
              data:data.avg_price,
          },
      ]
   })
       },
       error: function(){
       }
     });
   

   //3_2
   var histogramChart2 = echarts.init(document.getElementById('histogramChart2'));
   histogramChart2.setOption({
color:["#87cefa","#ff7f50","#32cd32","#da70d6",],
      tooltip : {
           trigger: 'item',
           formatter: "{a}<br/>{b}<br/>{c}"
       },
	   tooltip : {
			axisPointer : {
				type: 'none',
			},
			trigger: 'axis',
			position : function(point,params,dom,rect,size){
				//其中params为当前鼠标的位置
				return [params[0],'100%'];
			}
		},
       legend: {
        data:['放入浏览次总次数','放入购物车总次数','购买总次数'],
        y: '30px',
        x:'center',
        textStyle: {
                       color: '#fff',
                       fontSize:20
                   }
      },
      grid:{
		top:'25%',
        left: '5%',
        right: '5%',
        bottom: '0%',
        containLabel: true
      },
      calculable : true,
      xAxis : [
          {
              type : 'category',
              boundaryGap : false,
              data : ['1433','2423','1323','4252','商品类目5','4654','3243'],
              axisLine:{
                   lineStyle:{
                       color: '#87cefa'
                   },
               },
               axisLabel : {
                 interval:0,
                 rotate:40,

                   textStyle: {
                       color: '#fff',
                       fontSize:20
                   }
               }
          }
      ],
      yAxis : [
          {
              type : 'value',
              axisLine:{
                  lineStyle:{
                      color: '#87cefa'
                  },
              },
              splitLine: {
                  "show": false
              },
              axisLabel: {
                  textStyle: {
                       color: '#fff',
                       fontSize:20
                   },
                  formatter: function (value) {
                      return value
                  },
              },
          }
      ],
      series : [
          {
              name:'放入浏览次总次数',
              type:'line',
              smooth:true,
              itemStyle: {normal: {areaStyle: {type: 'default'}}},
              data:[10, 12, 21, 54, 260, 830, 710]
          },
          {
              name:'放入购物车总次数',
              type:'line',
              smooth:true,
              itemStyle: {normal: {areaStyle: {type: 'default'}}},
              data:[30, 182, 434, 791, 390, 30, 10]
          },
          {
              name:'购买总次数',
              type:'line',
              smooth:true,
              itemStyle: {normal: {areaStyle: {type: 'default'}}},
              data:[1320, 1132, 601, 234, 120, 90, 20]
          }
      ]
   })

   

   //4_2
   var pieChart1 = echarts.init(document.getElementById('pieChart1'));
   $.ajax({
       type: "get",
       async: false,
        url: "http://120.79.23.50:9988/AA/data/4_2.json", 
  context: document.body,
       success: function(data){
		   
	console.log("1");
		  console.log(data.step_name);
		  pieChart1.setOption({
	   color:["#87cefa","#ff7f50","#32cd32","#da70d6",],
     title : {
            },
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c}%",
				
            },
            legend: {
			textStyle: {
                       color: '#fff',
                       fontSize:20
                   },
                data : data.step_name,
				y:'35px'
            },
            calculable : true,
			grid:{
				top:80
			},
            series : [
				
                {
                    name:'漏斗图',
                    type:'funnel',
                    width: '40%',
                    data:[
                        {value:parseInt(data.click_nums[0]*100/data.click_nums[0]), name:data.step_name[0]},
                        {value:parseInt(data.click_nums[1]*100/data.click_nums[0]), name:data.step_name[1]},
                        {value:parseInt(data.click_nums[2]*100/data.click_nums[1]), name:data.step_name[2]},
                        {value:parseInt(data.click_nums[3]*100/data.click_nums[2]), name:data.step_name[3]}
                    ]
                }
            ]
   })
       },
       error: function(){
       }
     });
   

   //4_1

   var pieChart2 = echarts.init(document.getElementById('pieChart2'));
   $.ajax({
       type: "get",
       async: false,
        url: "http://120.79.23.50:9988/AA/data/4_1.json", 
  context: document.body,
       success: function(data){
		   
	console.log("1");
		  console.log(data.cate_id);
		  pieChart2.setOption({
		color:["#87cefa","#ff7f50","#32cd32","#da70d6",],
      tooltip : {
           trigger: 'item',
           formatter: "{a}<br/>{b}<br/>{c}元"
       },
	   tooltip : {
			axisPointer : {
				type: 'none',
			},
			trigger: 'axis',
			position : function(point,params,dom,rect,size){
				//其中params为当前鼠标的位置
				return [params[0],'90%'];
			}
		},
      grid:{
		top:'25%',
        left: '5%',
        right: '5%',
        bottom: '0%',
        containLabel: true
      },
      calculable : true,
      xAxis : [
          {
              type : 'category',
              boundaryGap : false,
              data : data.cate_id,
              axisLine:{
                   lineStyle:{
                       color: '#87cefa'
                   },
               },
               axisLabel : {
                 interval:0,
                 rotate:40,

                   textStyle: {
                       color: '#fff',
                       fontSize:13
                   }
               }
          }
      ],
      yAxis : [
          {
              type : 'value',
              axisLine:{
                  lineStyle:{
                      color: '#87cefa'
                  },
              },
              splitLine: {
                  "show": false
              },
              axisLabel: {
                  textStyle: {
                      color: '#fff'
                  },
                  formatter: function (value) {
                      return value + "元"
                  },
              },
          }
      ],
      series : [
          {
              name:'广告收入',
              type:'line',
              smooth:true,
              itemStyle: {normal: {areaStyle: {type: 'default'}}},
              data:data.sum_price,
			  
          }
		  
      ]
   })
       },
       error: function(){
       }
     });
   

 }
